<template>
	<view>
		<loading-view v-if="showLoading"></loading-view>
		<!-- <u-notice-bar :show="showTips" mode="horizontal" :list="list" :font-size="26" :close-icon="true" :speed="100"
			@close="showTips=false"></u-notice-bar> -->
		<view class="user-spread">
			<view class="header p-t-40 m-b-50 flex row-between">
				<view class="user-info flex m-l-30">
					<view class="user-avatar">
						<u-image width="110rpx" height="110rpx" borderRadius="50%"  :src="userInfo.user.avatar" />
					</view>
					<view class="user-message m-l-20 white">
						<view class="m-b-10">
							<view v-if="vipState==2" class="xxl bold  m-r-20 black">{{distributionInfo.distribution_agent_name}} 的小店</view>
							<view v-else class="xxl bold  m-r-20 black">{{userInfo.user.nickname}} </view>
						</view>
						<view class=" text-center m-b-10">
							<button @click.stop="shareShop"
								style="background-color: #f9f9f9;line-height: 44rpx;border-radius: 31rpx;margin-left: 20rpx;width: 100rpx;border:#000 1px solid;">分享</button>
						</view>
					</view>
				</view>
				<view class="flex">
					<view v-if="isShowShareBtn" class="invite-copy-btn m-r-20 xxs" @tap="showShareBtn = true">邀请开店</view>
				</view>
			</view>

			<view class="main">
				<!-- 填表格 -->
				<view v-if="vipState == 0" class="user-apply-box">
					<view class="user-apply-vip flex-col col-center">
						<view class="user-apply-header flex-col col-center">
							<view v-if="isShowText" class="title xxl normal">申请成为代理商</view>
							<view v-else class="title xxl normal">申请成为店主</view>
						</view>
						<view class="vip-form">
							<view class="form-item">
								<u-field v-model="distributionAgentName" :label-width="150" label="店铺名称：" :border-bottom="false"
									placeholder="请输入您的店铺名" required="true" :maxlength="12">
								</u-field>
							</view>
							<view class="form-item">
								<u-field v-model="realName" :label-width="150" label="真实姓名：" :border-bottom="false"
									placeholder="请输入您的真实姓名" required="true" :maxlength="10">
								</u-field>
							</view>

							<view class="form-item">
								<u-field v-model="mobile" :label-width="150" label="手机号码：" :border-bottom="false"
									placeholder="请输入您的手机号码" required="true" :maxlength="11">
								</u-field>
							</view>
							<view class="form-item">
								<u-field v-model="inviteOpenCode" :label-width="150" label="开店邀请：" :border-bottom="false"
									placeholder="请输入您的开店邀请码" disabled="true" required="true">
								</u-field>
							</view>
							<view class="form-item" @tap="showRegion=true">
								<u-field v-model="region" disabled right-icon="arrow-right" :label-width="150"
									label="现住省份：" :border-bottom="false" placeholder="请选择省、市、区" required="true">
								</u-field>
							</view>
							<view class="form-item">
								<u-field v-model="reason" :label-width="150" type="textarea" label="申请原因："
									placeholder="（请填写您的申请原因）" :field-style="{ height: '250rpx'}" />
							</view>
							<view class="form-item flex p-l-20">
								<view class="p-l-20 service">
									<text>客服微信:</text>
								</view>
								<view class="p-l-20 service-text">
									<u-upload :header="{token: $store.getters.token}" :max-count="1" :action="action" :file-list="fileList" :show-progress="false" upload-text="上传微信二维码,作为店铺客服" @on-success="onSuccess"  @on-remove="onRemove"></u-upload>
								</view>
							</view>
							<view class="form-item flex p-l-20">
								<view class="p-l-20">
									<text>营业执照:</text>
								</view>
								<view class="p-l-20 flex service-text">
									<u-upload :header="{token: $store.getters.token}" :max-count="1" :action="action" :file-list="fileList" :show-progress="false" upload-text="请上传营业执照正面" @on-success="onSuccessFront"  @on-remove="onRemoveFront"></u-upload>
									<u-upload :header="{token: $store.getters.token}" :max-count="1" :action="action" :file-list="fileList" :show-progress="false" upload-text="请上传营业执照背面" @on-success="onSuccessBack"  @on-remove="onRemoveBack"></u-upload>
								</view>
							</view>
						</view>
					</view>
					<button class="apply-btn bg-primary white md m-t-20 flex row-center br60" @tap="formSubmit">
						立即申请
					</button>
					<view class="m-b-30 m-t-20 sm flex row-center">
						<u-checkbox v-model="isAgreement" shape="circle">
							<view class="flex">
								已阅读并同意
								<router-link to="/bundle/pages/server_explan/server_explan?type=3">
									<view class="primary">《入驻协议》</view>
								</router-link>
							</view>
						</u-checkbox>
					</view>
					<view class="xxs lighter flex row-center">提交成功后，我们将会在1-2个工作日内给您回复</view>
				</view>

				<!-- 申请状态 -->
				<view v-if="vipState==1" class="user-result-box">
					<view class="user-result flex-col col-center">
						<view class="user-result-header flex-col col-center">
							<view v-if="isShowText" class="title xxl normal">申请成为代理商</view>
							<view v-else class="title xxl normal">申请成为店主</view>
						</view>
						<view class="user-result-content flex-col col-center">
							<image class="apply-result-img"
								:src="applyObject.status == 2 ?imgUrl+'/static/images/icon_fail.png' :imgUrl+'/static/images/icon_success.png'" />
							<view class="m-t-10 nr" style="line-height: 40rpx">{{applyObject.status_str}}</view>
							<view class="apply-fail-reason sm"
								:style="applyObject == 2 ? 'visibility: none' : 'visibility: hidden'">
								{{applyObject.reason}}
							</view>
						</view>
						<view class="user-result-info">
							<view class="info-item flex nr">
								<view class="label">真实姓名：</view>
								<view class="info-text ml20">{{applyObject.real_name}}</view>
							</view>
							<view class="info-item flex nr">
								<view class="label">手机号码：</view>
								<view class="info-text ml20">{{applyObject.mobile}}</view>
							</view>
							<view class="info-item flex nr">
								<view class="label">现住省份：</view>
								<view class="info-text ml20">{{applyObject.province}} {{applyObject.city}}
									{{applyObject.district}}
								</view>
							</view>
							<view class="info-item flex nr">
								<view class="label">申请原因：</view>
								<view class="info-text ml20">{{applyObject.reason ? applyObject.reason : '-'}}</view>
							</view>
						</view>
					</view>
					<view v-if="applyDetailStatus==2" :class="'white m-t-20 br60 apply-btn flex row-center md bg-primary'" @tap="reApply">重新申请
					</view>
					<view v-if="openShopCondition" class="m-t-20 xxs lighter flex row-center"><text style="color: blue;" @tap="goEarnet">缴纳并查看我的保证金保证金</text></view>
					<view class="m-t-20 xxs lighter flex row-center">提交成功后，我们将会在1-2个工作日内给您回复</view>
				</view>

				<!-- 已申请 -->
				<view v-if="vipState==2" class="user-vip">
					
					<!-- <view class="user-assets-box">
						<view class="usual-tools-header flex lg">
							我的店铺销售
						</view>
						<view class="user-assets-content flex  flex-wrap text-center">
							<view class="user-item flex-col col-center">
								<view class="nr flex" style="color: #333333">
									上月店铺销售
									<u-icon class="ml10" name="question-circle" size="30rpx" color="#D88D5A" />
								</view>
								<view class="assets m-l-20">
									<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
										:price="distributionInfo.team_sale_info.last_month_my_shop" :color="colorConfig.primary" />
								</view>
							</view>
							<view class="user-item flex-col col-center">
								<view class="nr flex" style="color: #333333">
									本月店铺销售
									<u-icon class="ml10" name="question-circle" size="30rpx" color="#D88D5A" />
								</view>
								<view class="assets m-l-20">
									<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
										:price="distributionInfo.team_sale_info.this_month_my_shop" :color="colorConfig.primary" />
								</view>
							</view>
						</view>
					</view> -->
					
					<!-- <view class="user-assets-box m-t-20">
						<view class="user-assets-header flex row-between">
							<view class="flex nr bold" style="line-height: 80rpx;color: #333333;">
								可提现佣金：
								<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
									:price="distributionInfo.able_withdrawal" :color="colorConfig.primary" />
							</view>
							<navigator hover-class="none" class="primary-btn white flex row-center"
								url="/bundle/pages/user_withdraw/user_withdraw">立即提现</navigator>
						</view>
						<view class="user-assets-content flex  flex-wrap">
							<view class="user-item flex-col col-center">
								<tool-tip v-if="false" class="m-t-20" id="today-profit" content="今日预估收益金额"
									style="position: absolute;right: -66rpx;"></tool-tip>
								<view class="nr user-assets-name flex" style="color: #333333">
									今日预估收益
									
								</view>
								<view class="assets m-l-20">
									<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
										:price="distributionInfo.today_earnings" :color="colorConfig.primary" />
								</view>
							</view>
							<view class="user-item flex-col col-center">
								<view class="nr user-assets-name flex" style="color: #333333">
									本月预估收益
									
								</view>
								<view class="assets m-l-20">
									<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
										:price="distributionInfo.month_earnings" :color="colorConfig.primary" />
								</view>
							</view>
							<view class="user-item flex-col col-center">
								<view class="nr user-assets-name flex" style="color: #333333">
									累计获得收益
									
								</view>
								<view class="assets">
									<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
										:price="distributionInfo.history_earnings" :color="colorConfig.primary" />
								</view>
							</view>
						</view>
					</view> -->
					<!-- <view class="user-assets-box m-t-20" v-if="isShowShareBtn||isShowShareBtn2">
						<view class="usual-tools-header flex lg">
							我的团队
						</view>
						<view class="user-assets-content flex  flex-wrap text-center">
							<router-link class="user-item flex-col col-center" to="{path: '/bundle/pages/user_fans/user_fans', query: {type_id: 1}}">
								<view class="nr flex" style="color: #333333">
									上月团队销售
									<u-icon name="arrow-right" size="26rpx" />
									
								</view>
								<view class="assets m-l-20">
									<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
										:price="distributionInfo.team_sale_info.last_month" :color="colorConfig.primary" />
								</view>
							</router-link>
							<router-link class="user-item flex-col col-center" to="{path: '/bundle/pages/user_fans/user_fans', query: {type_id: 0}}">
								<view class="nr flex" style="color: #333333">
									本月团队销售
									<u-icon name="arrow-right" size="26rpx" />
									
								</view>
								<view class="assets m-l-20">
									<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
										:price="distributionInfo.team_sale_info.this_month" :color="colorConfig.primary" />
								</view>
							</router-link>
						</view>
					</view> -->
					<!-- <view class="mt20 fans-msg-box flex bg-white md">
						<router-link  class="flex-1" to="/bundle/pages/user_fans/user_fans">
							<view class="my-fans flex row-center normal">
								我的团队 <view class="primary m-l-10">{{distributionInfo.fans}}</view>
								<u-icon class="m-l-10" name="arrow-right" size="28rpx" color="#666" />
							</view>
						</router-link>
						
				
					</view> -->
					<view class="usual-tools-box bg-white m-t-20">
						<view class="usual-tools-header flex lg">
							店铺工具
						</view>
						<view class="usual-content flex">
					
							<router-link class="usual-item" :to="{path:'/bundle/pages/user_spread_order/user_spread_order',query:{level:1,date:'today'}}">
								<view class="flex-col col-center">
									<image :src="imgUrl + '/static/images/icon_fenxiao.png'" class="usual-item-img"></image>
									<view class="nr normal m-t-20" style="line-height: 40rpx">分销订单</view>
								</view>
							</router-link>
							<router-link class="usual-item" to="/bundle/pages/commission_details/commission_details">
								<view class="flex-col col-center">
									<image :src="imgUrl + '/static/images/icon_yongjin.png'" class="usual-item-img"></image>
									<view class="nr normal m-t-20" style="line-height: 40rpx">佣金明细</view>
								</view>
							</router-link>
							<router-link class="usual-item" to="/bundle/pages/monthly_bill/monthly_bill">
								<view class="flex-col col-center">
									<image :src="imgUrl + '/static/images/icon_zhangdan.png'" class="usual-item-img"></image>
									<view class="nr normal m-t-20" style="line-height: 40rpx">月度账单</view>
								</view>
							</router-link>
							<router-link class="usual-item" to="/bundle/pages/shop_revise/shop_revise">
								<view class="flex-col col-center">
									<image :src="imgUrl + '/static/images/shezhi.png'" class="usual-item-img"></image>
									<view class="nr normal m-t-20" style="line-height: 40rpx">店铺设置</view>
								</view>
							</router-link>
						</view>
					</view>
				</view>
			</view>
			<!-- <u-popup v-model="showPop" mode="center" closeable border-radius="30">
				<view class="inviteform-contain flex-col col-center">
					<view class="title xl">填写邀请人</view>
					<view class="input-row flex">
						<view style="width: 140rpx;">邀请码：</view>
						<u-input :clearable="false" v-model="inviteCode" placeholder="请输入邀请码" ></u-input>
					</view>
					<view class="btn bg-primary white flex row-center" @tap="bindSuperiorFun">确定</view>
				</view>
			</u-popup> -->
			<share-popup v-model="showShareBtn" :share-id="distribution.id" pagePath="bundle/pages/user_spread/user_spread" type="3"
				:config="{
				avatar:shopAvatar,
				nickname:userInfo.user.nickname,
				image:appConfig.invite.poster,
				name:appConfig.invite.slogan,
				miniUrl:userInfo.mini_url,
				level_id:1,
			  }" />
			<share-popup v-model="showShareBtn2" :share-id="distribution.id" pagePath="bundle/pages/user_spread/user_spread" type="3"
						 :config="{
				avatar:userInfo.user.avatar,
				nickname:userInfo.user.nickname,
				image:appConfig.invite.poster,
				name:appConfig.invite.slogan,
				miniUrl:userInfo.mini_url,
				level_id:2,
			  }" />
			<share-popup :show="showShareBtn" @close="showShareBtn = false" :img-url="appConfig.invite.poster"
				:summary="appConfig.invite.slogan" :share-title="userInfo.user.nickname"></share-popup>
			
			<share-popup v-model="showShareShopBtn" :mnpqrcodepre="mnpqrcodepre" :share-id="distribution.id" pagePath="pages/index/index" type="2"
			 :config="{
				avatar: userInfo.user.avatar,
				nickname: distribution.distribution_agent_name || userInfo.user.nickname,
				image: poster,
				name: distribution.distribution_agent_name,
				slogin:slogan,
				miniUrl:mini_url,
			  }" />
			
			<share-popup :show="showShareShopBtn" @close="showShareShopBtn = false" :goods-id="distribution.id" :img-url="poster"
				:summary="slogan" :share-title="distribution.distribution_agent_name"></share-popup>	
				
				
			<u-select v-model="showRegion" mode="mutil-column-auto" @confirm="regionChange" :list="regionLists">
			</u-select>
		</view>
	</view>

</template>

<script>
	import {
		apiMnpQrCode,
		apiTtQrCode
	} from "@/api/app"
	import {
		baseURL
	} from '@/config/app.js';
	import {
		mapGetters
	} from 'vuex';
	import {
		bindSuperior,
		applyDistribute,
		applyDetail,
		getSuperiorInfo,
		getDistribution,
		veryfiyDistribute
	} from "@/api/user";
	import {
		toLogin
	} from '@/utils/login'
	import area from '@/utils/area'
	import {INVITE_CODE,INVITE_RANDOM_CODE,INVITE_LEVEL_ID,INVITE_REGISTER} from '@/config/cachekey'
	import Cache from '@/utils/cache'
	import {
		copy
	} from '@/utils/tools'
	export default {
		data() {
			return {
				poster:'',
				slogan:'',
				mini_url: "",
				action: baseURL + '/api/file/formimage',
				list: ['成为店主，推广下级可获得额外收益，推广越多收益越多'],
				showTips: true,
				showLoading: true,
				// 弹窗展示
				showShareShopBtn:false,
				showShareBtn: false,
				showShareBtn2: false,
				showPop: false,
				//店铺名称
				distributionAgentName:'',
				//客服微信
				businessCard: '',
				businessLicenseFront:'',
				businessLicenseBack:'',
				mobile: '',
				realName: '',
				reason: '',
				region: '',
				// 省id
				provinceId: -1,
				// 市id
				cityId: -1,
				// 区ID
				districtId: -1,
				// 推销状态 0 ==> 未申请 1 ==> 申请进度 2 ==> 已申请
				vipState: 0,
				vipStates: 0,
				userInfo: {
					user: {},
					leader: {}
				},
				// 审核信息对象
				applyObject: {},
				// 邀请人状态
				inviteStatus: false,
				showRegion: false,
				regionLists: area,
				distribution:{},
				distributionInfo: {},
				//审核状态，是否可以重新申请
				applyDetailStatus: 0,
				//入驻协议
				isAgreement:false,
				imgUrl:`${this.$imgUrl}/wechat`,
				mnpqrcodepre:''
			};
		},
		onLoad(options) {
			// 获取上级及个人信息
			this.getSuperiorInfoFun()
			// 判断是否是店主
			this.veryfiyDistributeFun()
			// console.log("userInfo",this.userInfo)
			this.goLogin()
			console.log('=======this.distributionInfo=====');
			console.log(this.distributionInfo);
			
			console.log('----this.appConfig.share.mnp_share_image-------------');
			console.log(this.appConfig.share.mnp_share_image);
			this.poster = this.appConfig.share.mnp_share_image
			this.slogan = this.appConfig.share.mnp_share_title
			this.getPoster()
		},
		onShareAppMessage() {
			console.log('------------this.appConfig--------------------');
			console.log(this.appConfig);
			
			console.log('-------------this.$store----------------');
			console.log(this.$store);
			return {
				title: this.appConfig.invite.slogan,
				imageUrl: this.appConfig.invite.poster,
				path: '/bundle/pages/user_spread/user_spread?distributionId=' + this.$store.getters.distribution.id + "&invite_code=" + this.$store.getters.inviteCode
			};
		},

		computed: {
			...mapGetters(['token', 'appConfig','distribution','isLogin']),
			isShowShareBtn(){
				const isShowShareBtn = this.appConfig.invite.invite_appoint_user.includes(this.distribution.level_id)
				console.log('=======isShowShareBtn===========');
				console.log(this.appConfig.invite);
				console.log(this.distribution);
				console.log(isShowShareBtn);
				return this.vipState==2&&this.distribution.is_distribution&&this.distribution.id ? isShowShareBtn:false
			},
			shopAvatar(){
				console.log('========this.userInfo.user.avatar=========');
				console.log(this.userInfo.user.avatar);
				return this.userInfo.user.avatar;// || this.distributionInfo.user.avatar;
			},
			openShopCondition(){
				return this.appConfig.invite.open_shop_condition==2?true:false
			},
			isShowShareBtn2(){//邀请成为代理商
				return this.vipState==2&&this.distribution.is_distribution&&this.distribution.id == 1 ? true:false
			},
			isShowText(){//申请成为代理商
				const lid = Cache.get(INVITE_LEVEL_ID)||0
				return this.vipState!=2&&lid == 2 ? true:false
			},
			inviteOpenCode(){
				return Cache.get(INVITE_REGISTER)||''
			},
			inviteRandomCode(){
				return Cache.get(INVITE_RANDOM_CODE)||''
			}
		},
		methods: {
			async getPoster() {
				if(this.$store.getters.inviteCode){
					const res = await this.getMnpQrcode()
					this.mnpqrcodepre = res.data.qr_code.replaceAll("\r\n", "")
					// console.log('-------this.mnpqrcodepre-----------');
					// console.log(this.mnpqrcodepre);
				}
			},
			getMnpQrcode() {
				return new Promise((resolve, reject) => {
					apiMnpQrCode({
						id: this.distribution.id,
						url: 'pages/index/index',
						type: 2,
						invite_code: this.$store.getters.inviteCode,
					}).then((res) => {
						resolve(res)
					}).catch(() => {
						reject()
					})
				})
			},
			shareShop(id) {
				/* this.getPoster() */
				this.showShareShopBtn = true
			},
			goLogin() {
				let {
					isLogin
				} = this;
				if (!isLogin) {
					uni.navigateTo({
						url: '/pages/login/login'
					});
				}
				
			},
			goEarnet(){
				uni.navigateTo({
					url: '/bundle/pages/user_wallet/user_wallet'
				});
			},
			onSuccess(e) {
				this.businessCard=e.data.base_uri
				this.vipState = 0
			},
			onSuccessIDFront(e) {
				this.businessLicenseFront=e.data.base_uri
				this.vipState = 0
			},
			onSuccessIDBack(e) {
				this.businessLicenseBack=e.data.base_uri
				this.vipState = 0
			},
			onSuccessFront(e) {
				this.businessLicenseFront=e.data.base_uri
				this.vipState = 0
			},
			onSuccessBack(e) {
				this.businessLicenseBack=e.data.base_uri
				this.vipState = 0
			},
			onRemove(index) {
				this.businessCard=''
				this.vipState = 0
			},
			onRemoveFront(index) {
				this.businessLicenseFront=''
				this.vipState = 0
			},
			onRemoveBack(index) {
				this.businessLicenseBack=''
				this.vipState = 0
			},
			// 店主信息
			async getDistributionFun() {
				const {
					data,
					code
				} = await getDistribution()
				if (code == 1) {
					this.showLoading = false
					this.distributionInfo = data
					this.distribution = this.distributionInfo.distribution
					console.log('=======this.distributionInfo=========================')
					console.log(this.distributionInfo)
				}
			},

			veryfiyDistributeFun() {
				veryfiyDistribute().then(res => {
					if (res.code == 10001) {
						// 店主
						this.vipState = 2
						this.getDistributionFun()
					} else if (res.code == 20001) {
						// 非店主
						this.vipState = 0;
						if(!Cache.get("VIPSTATES")){
						this.applyDetailFun()
						}
					} else if (res.code == 0) {
						// 返回上一页
						setTimeout(() => {
							uni.navigateBack()
						}, 500)
					}
				})
			},

			// 最新店主申请详情
			async applyDetailFun() {
				const {
					data,
					code
				} = await applyDetail()
				if (code == 1) {
					this.showLoading = false
					this.applyDetailStatus=data.status
					switch (data.status) {
						case 0:
							// 待审核
						case 2:
							// 审核不通过
							this.vipState = 1;
							this.applyObject = data
							break;
					}
				}
			},
			goPage(url) {
				return toLogin()
				uni.navigateTo({
					url
				});
			},
			reApply() {
				this.vipState = 0;
				Cache.set("VIPSTATES",1);
			},

			regionChange(region) {
				this.region = region[0].label + " " + region[1].label + " " + region[2].label
				this.provinceId = region[0].value;
				this.cityId = region[1].value;
				this.districtId = region[2].value
			},

			async formSubmit() {
				let {
					provinceId,
					distributionAgentName,
					cityId,
					businessCard,
					businessLicenseFront,
					businessLicenseBack,
					districtId,
					reason,
					mobile,
					realName,
					region,
					isAgreement
				} = this;
				Cache.remove("VIPSTATES");
				if (!distributionAgentName) {
					this.$toast({
						title: "请填写店铺名称"
					});
					return;
				}

				if (!realName) {
					this.$toast({
						title: "请填写真实姓名"
					});
					return;
				}

				if (!region.length) {
					this.$toast({
						title: "请选择省市区"
					});
					return;
				}
				if (!isAgreement) {
					this.$toast({
						title: '请先勾选"已阅读并同意《服务协议》和《隐私协议》"'
					});
					return;
				}

				let params = {
					distribution_agent_name: distributionAgentName,
					real_name: realName,
					province: provinceId,
					city: cityId,
					district: districtId,
					reason: reason,
					business_license_front:businessLicenseFront,
					business_license_back:businessLicenseBack,
					business_card: businessCard,
					code: this.inviteOpenCode,
					random_code: this.inviteRandomCode,
					level_id: Cache.get(INVITE_LEVEL_ID),
					mobile
				};
				const {
					data,
					code,
					msg
				} = await applyDistribute(params)
				if (code == 1) {
					this.$toast({
						title: '提交成功请等待审核'
					});
					setTimeout(()=>{
						uni.navigateTo({
							url: '/bundle/pages/user_spread/user_spread'
						});
					},1000)
				}else{
					this.$toast({
						title: msg
					});
					return;
				}
			},


			// 填写邀请码
			bindSuperiorFun() {
				bindSuperior({
					code: this.inviteCode
				}).then(res => {
					this.$toast({
						title: res.msg
					})
					if (res.code == 1) {
						this.showPop = false
						this.getSuperiorInfoFun();
					}
				});
			},

			showInvitePop() {
				this.showPop = true;
			},

			// 获取邀请人信息
			async getSuperiorInfoFun() {
				const {
					data,
					code
				} = await getSuperiorInfo()
				if (code == 1) {
					this.userInfo = data
				}
			},
			onCopy() {
				copy(this.userInfo.user.distribution_code)
			},

		}
	};
</script>
<style lang="scss">
	.user-spread {
		// background: linear-gradient(180deg, rgba(239, 108, 0, 1) 0%, rgba(246, 246, 246, 1) 74%);
		

		.header {

			.user-info {
				.user-avatar {
					position: relative;

				
				}
				.avatar-tag {
					display: inline-block;
					background-color: #00632B;
					border: 1rpx solid #FFFFFF;
					border-radius: 100rpx;
					line-height: 32rpx;
					padding: 0 10rpx;
				}
				.user-message {
					.write-btn {
						height: 42rpx;
						width: 100rpx;
						background-color: #FF838D;
					}
				}
			}
		}
		.invite-copy-btn {
			line-height: 30rpx;
			padding: 10rpx;
			border: 1rpx solid #00632B;
			color: #00632B;
			border-radius: 50rpx;
		}

		.main {
			padding: 0 20rpx;

			.user-vip {
				.user-assets-box {
					background-color: #fff;
					border-radius: 20rpx;
					padding: 10rpx 20rpx 22rpx;
					background: #fff;
					.usual-tools-header {
						height: 100rpx;
						line-height: 44rpx;
						border-bottom: $-solid-border;
					}
					.user-assets-header {
						border-bottom: $-solid-border;
						padding-bottom: 4rpx;

						.primary-btn {
							height: 54rpx;
							border-radius: 120rpx;
							width: 144rpx;
							background: #00632B;
						}
					}

					.user-assets-content {
						margin-top: 30rpx;

						.user-item {
							flex: 1;
							position: relative;

							.user-assets-name {
								text-align: center;
								
							}

							.assets {
								margin-top: 14rpx;
								text-align: center;
								
							}
						}
					}
				}

				.fans-msg-box {
					margin-top: 20rpx;
					border-radius: 10rpx;
					line-height: 42rpx;

					.my-fans {
						height: 120rpx;
					}

					.line {
						width: 3rpx;
						height: 60rpx;
						background-color: #E5E5E5;
					}

					.invite-fans {
						height: 120rpx;
					}
				}

					
				.usual-tools-box {
					border-radius: 10rpx;
					padding: 0 25rpx;

					.usual-tools-header {
						height: 100rpx;
						line-height: 44rpx;
						border-bottom: $-solid-border;
					}

					.usual-content {
						padding: 40rpx 0;

						.usual-item {
							width: 25%;

							.usual-item-img {
								width: 56rpx;
								height: 56rpx;
								flex: none;
							}

						}
					}
				}
			}

			.user-apply-box {
				.user-apply-vip {
					background-color: white;
					padding: 40rpx 0 0rpx;
					border-radius: 20rpx;

					.title {
						line-height: 30rpx;
						font-weight: bold;
					}

					.explain {
						margin-top: 20rpx;

						image {
							width: 24rpx;
							height: 24rpx;
							flex: none;
						}

						span {
							font-size: 20rpx;
							line-height: 30rpx;
						}
					}

					.vip-form {
						width: 100%;
						margin-top: 60rpx;

						.form-item {
							border: $-solid-border;
							margin: 0 30rpx 30rpx;
							position: relative;
							
							.service::before {
								content: '*';
								position: absolute;
								left: 25rpx;
								top:50%;
								 transfrom: translate(0, -50%);
								font-size: 14px;
								color: $u-type-error;
								height: 9px;
								line-height: 17rpx;
							}
							.service-text {
								text-align: center;
							}
						}
					}
				}

				.apply-btn {
					line-height: 30rpx;
					height: 82rpx;
				}
			}

			.user-result-box {
				.user-result {
					background-color: white;
					padding: 36rpx 14rpx 50rpx;
					border-radius: 20rpx;

					.user-result-header {
						.title {
							line-height: 30rpx;
							font-weight: bold;
						}

					}
					.user-result-content {
						padding: 60rpx 0 22rpx;
						width: 100%;
						border-bottom: $-solid-border;

						.apply-result-img {
							width: 100rpx;
							height: 100rpx;
						}
					}

					.user-result-info {
						margin-top: 42rpx;
						width: 100%;

						.info-item {
							margin-left: 60rpx;
							margin-bottom: 28rpx;
							line-height: 30rpx;

							.label {
								width: 140rpx;
							}
						}
					}
				}

				.apply-btn {
					line-height: 30rpx;
					height: 82rpx;
				}

				.bg-gray {
					background-color: #CCCCCC;
				}
			}
		}
	}


	.main .user-apply-box .apply-btn {
		line-height: 30rpx;
		height: 82rpx;
	}

	.main .user-result-box .user-result-content .apply-fail-reason {
		color: $-color-primary;
		line-height: 36rpx;
		margin-top: 10rpx;
	}

	/* 弹窗 */
	.inviteform-contain {
		padding-left: 30rpx;
		padding-right: 30rpx;
		padding-bottom: 30rpx;
		width: 580rpx;
		border-radius: 6rpx;
		background-color: $-color-white;
	}

	.inviteform-contain .title {
		padding: 26rpx 0rpx;
	}

	.inviteform-contain .modify-row {
		padding: 32rpx 0px;
		width: 100%;
		border-bottom: 1rpx solid #E5E5E5;
	}

	.inviteform-contain .btn {
		height: 80rpx;
		padding: 0 180rpx;
		border-radius: 10rpx;
		margin-top: 60rpx;
	}

</style>
